#ifndef SERVICE_SHARED_SERVER_DEF_H
#define SERVICE_SHARED_SERVER_DEF_H

#include <game_share/game_def.h>
#include <nel/net/message.h>
#include <nel/net/unified_network.h>
#include <nel/net/callback_server.h>
#include <game_share/error_type.h>
#include <nel/misc/log.h>
#include <nel/misc/debug.h>

NLMISC::CLog& getGlobal_Loger();

#define  Network NLNET::CUnifiedNetwork::getInstance()

#define  packT2C( id, submsg ) \
	CMessage msgout("T2C");	\
	msgout.serial(id);		\
	msgout.serialMessage(submsg);

inline void sendERR( DEF::ERROR_TYPE errNO, DEF::UID uid, NLNET::TServiceId sid )
{
	NLNET::CMessage msgout("ERR");
	msgout.serial(errNO);
	msgout.serial(uid);
	Network->send( sid, msgout );
}

inline void sendERR( DEF::ERROR_TYPE errNO, DEF::UID uid, std::string serviceName )
{
	NLNET::CMessage msgout("ERR");
	msgout.serial(errNO);
	msgout.serial(uid);
	Network->send( serviceName, msgout );
}

inline void sendERR( DEF::ERROR_TYPE errNO, NLNET::TSockId from, NLNET::CCallbackServer* pCallbackServer )
{
	NLNET::CMessage msgout("ERR");
	msgout.serial(errNO);
	pCallbackServer->send(msgout, from);
	pCallbackServer->disconnect (from);
}

#endif
